Document ObjectEach HTML document loaded into a browser window becomes a Document object.
The Document object provides access to all HTML elements in a page, from within a script.
Tip: The Document object is also part of the
Window object, and can be accessed through the window.document property.
Note: The Document object can also use the properties and methods of the Node object.
Methods Property | Description |
anchors | Returns a collection of all the anchors in the document |
applets | Returns a collection of all the applets in the document |
body | Returns the body element of the document |
cookie | Returns all name/value pairs of cookies in the document |
documentMode | Returns the mode used by the browser to render the document |
domain | Returns the domain name of the server that loaded the document |
forms | Returns a collection of all the forms in the document |
images | Returns a collection of all the images in the document |
lastModified | Returns the date and time the document was last modified |
links | Returns a collection of all the links in the document |
readyState | Returns the (loading) status of the document |
referrer | Returns the URL of the document that loaded the current document |
title | Sets or returns the title of the document |
URL | Returns the full URL of the document |
Methods Method | Description |
close() | Closes the output stream previously opened with document.open() |
getElementsByName() | Accesses all elements with a specified name |
open() | Opens an output stream to collect the output from document.write() or document.writeln() |
write() | Writes HTML expressions or JavaScript code to a document |
writeln() | Same as write(), but adds a newline character after each statement |